package com.amado.easyui2.service.impl;

import java.util.List;

import com.amado.easyui2.dao.UserDao;
import com.amado.easyui2.dao.impl.UserDaoMysqlImpl;
import com.amado.easyui2.dao.impl.UserDaoOracleImpl;
import com.amado.easyui2.domain.User;
import com.amado.easyui2.service.UserService;
import com.amado.easyui2.vo.Page;

public class UserServiceImpl implements UserService {
	private UserDao userDao = new UserDaoMysqlImpl();

	@Override
	public boolean add(User user) {
		if (user != null) {
			userDao.add(user);
			return true;
		}
		return false;
	}

	@Override
	public List<User> list(String name, String departmentNum) {
		return userDao.listAll(name, departmentNum);
	}

	@Override
	public Page<User> listAll(String name, String departmentNum, Page page) {
		int total = userDao.listAllCount(name, departmentNum);
		Page<User> newPage  = new Page<>();
		newPage.setTotal(total);
		newPage.setRows(userDao.listAll(name, departmentNum,page));
		return newPage;
	}

	@Override
	public boolean delete(Long id) {
		if(id!=null) {
			userDao.delete(id);
		}
		return false;
	}

	@Override
	public boolean update(User user) {
		if(user!=null) {
			userDao.update(user);
			return true;
		}
		return false;
	}

	@Override
	public List<User> list() {
		return userDao.list();
	}

	@Override
	public List<User> getUserName(User user) {
		if(user!=null) {
			userDao.login(user);	
		}
		return null;
	}

	
}
